from selenium.webdriver.common.by import By
from common.Utils import BlogDriver


# 测试博客编辑页面
class BlogEdit:
    url = ""
    driver = ""

    def __init__(self):
        self.url = "http://192.168.47.135:8653/blog_system/blog_edit.html"
        self.driver = BlogDriver.driver
        self.driver.get(self.url)

    # 正确发布博客（登陆状态下）
    def EditSucTestByLogin(self):
        self.driver.find_element(By.CSS_SELECTOR, "#title").send_keys("自动化测试创建")
        # 补充博客内容输入
        self.driver.find_element(By.CSS_SELECTOR, "#content").send_keys("这是自动化测试创建的博客内容")
        # 补充发布按钮点击
        self.driver.find_element(By.CSS_SELECTOR, "#submit").click()

    # 可以继续添加其他测试方法
    def EditWithoutTitle(self):
        # 测试不输入标题的情况
        self.driver.find_element(By.CSS_SELECTOR, "#content").send_keys("只有内容没有标题的测试")
        self.driver.find_element(By.CSS_SELECTOR, "#submit").click()

    def EditWithoutContent(self):
        # 测试不输入内容的情况
        self.driver.find_element(By.CSS_SELECTOR, "#title").send_keys("只有标题没有内容的测试")
        self.driver.find_element(By.CSS_SELECTOR, "#submit").click()